import Vue from 'vue'
import VueRouter from 'vue-router'

// 1.创建路由组件
import Home from '../views/Home.vue'
import User from '../views/User.vue'
import Main from '../views/Main.vue'
import Wstore from '../views/wStore/StoreManage.vue'
import Stock from '../views/wStore/StockManage.vue'
import SPermission from '../views/wStore/StorePermission.vue'
import Product from '../views/product/ProductManage.vue'

import EntryStore from '../views/stock/EntryStore.vue'
import OutStore from '../views/stock/OutStore.vue'

import Login from '../views/Login.vue'
import Register from '../views/Register.vue'

Vue.use(VueRouter)

// 2.将路由与组件进行映射
const routes = [
    // 主路由
    {
        path: '/',
        component: Main,
        redirect: '/home', // 重定向
        children: [
            // 子路由
            { path: '/home', component: Home }, // 主页
            { path: 'user', component: User }, // 用户管理
            { path: '/product', component: Product }, // 商品管理
            { path: '/wStore', component: Wstore }, // 仓库管理
            { path: '/stock', component: Stock }, // 仓库库存管理
            { path: '/sPermission', component: SPermission }, // 仓库权限管理
            { path: '/entryStore', component: EntryStore }, // 入库
            { path: '/outStore', component: OutStore }, // 出库
        ]
    },
    {
        path: '/login', // 登录
        name: 'login',
        component: Login,
    },
    {
        path: '/register', // 注册
        name: 'register',
        component: Register,
    }

]

// 3.创建router实例
const router = new VueRouter({
    routes // (缩写) 相当于 routes: routes
})

export default router